package com.tingfeng.config.response;

/**
 * 统一响应
 */
public class ResultModel{
    private Integer code;
    private String msg;
    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public ResultModel() {}

    public ResultModel(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 处理成功数据
     */
    public ResultModel(Object data) {
        this.setCode(0);
        this.setMsg("success");
        this.setData(data);
    }

    public ResultModel(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 处理成功数据
     */
    public static ResultModel ok() {
        return new ResultModel(0, "success");
    }

    /**
     * 处理失败数据
     */
    public static ResultModel fail(String msg) {
        return new ResultModel(1, msg);
    }


}